// 引入three.js
import * as THREE from 'three';
// pointsArrs：一个行政区包含一个或多个轮廓，一个轮廓对应pointsArrs的一个元素
function shapeMesh(pointsArrs) {
    var shapeArr = [];//轮廓形状Shape集合
    pointsArrs.forEach(pointsArr => {
        var vector2Arr = [];
        // 转化为Vector2构成的顶点数组
        pointsArr[0].forEach(elem => {
            vector2Arr.push(new THREE.Vector2(elem[0], elem[1]))
        });
        var shape = new THREE.Shape(vector2Arr);
        shapeArr.push(shape);
    });
    var material = new THREE.MeshBasicMaterial({
        transparent:true,
        opacity:0.5,
        color: 0xffffff,
        side: THREE.DoubleSide, //两面可见
    }); //材质对象
    var geometry = new THREE.ExtrudeGeometry(
        shapeArr,
        {
            depth: 1, //拉伸高度
            bevelEnabled: false
        }
    );
    var mesh = new THREE.Mesh(geometry, material); //网格模型对象
    mesh.position.set(-104,-35,0)
    return mesh;
}
export { shapeMesh };